﻿<UserControl x:Class="MaxStoreShop.WarehouseModule.Characters.CharacterEditor.CharacterEditorView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:characterEditor="clr-namespace:MaxStoreShop.WarehouseModule.Characters.CharacterEditor"
             xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
             xmlns:converters="clr-namespace:MaxStoreErp.Core.Converters;assembly=MaxStoreErp.Core"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:directories="clr-namespace:MaxStoreShop.Domain.Directories;assembly=MaxStoreShop.Domain"
             xmlns:drop="clr-namespace:MaxStoreErp.Core.Ui.Drop;assembly=MaxStoreErp.Core"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
             xmlns:validators="clr-namespace:MaxStoreShop.Logic.Validators;assembly=MaxStoreShop.Logic"
             Style="{DynamicResource EditorStyle}"
             d:DataContext="{d:DesignInstance characterEditor:CharacterEditorViewModel}"
             d:DesignHeight="300"
             d:DesignWidth="400"
             mc:Ignorable="d">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../../Resources/Shared.xaml" />
            </ResourceDictionary.MergedDictionaries>
            <converters:NullImageConverter x:Key="NullImageConverter" />
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            <StackPanel Background="#FF929191" Orientation="Vertical">
                <drop:DropBorder Name="CharacterImageBorder"
                                 Margin="6,6,6,0"
                                 BorderBrush="Bisque"
                                 BorderThickness="1"
                                 CornerRadius="6"
                                 UseLayoutRounding="True">
                    <Image Name="CharacterImage"
                           MinWidth="200"
                           MinHeight="200"
                           MaxWidth="200"
                           Margin="1"
                           AllowDrop="True"
                           DataContext="{Binding SelectedItem}"
                           Source="{Binding Photo,
                                            Converter={StaticResource NullImageConverter}}" />
                </drop:DropBorder>
                <StackPanel HorizontalAlignment="Center" Orientation="Horizontal">
                    <Button Width="44"
                            Height="44"
                            Margin="6"
                            BorderThickness="0"
                            Command="{Binding BrowsePhotoCommand}"
                            Style="{DynamicResource MetroCircleButtonStyle}"
                            TabIndex="7"
                            ToolTip="Найти и установить фотографию">
                        <Path Width="32"
                              Height="32"
                              Data="{StaticResource FolderIcon}"
                              Fill="{DynamicResource BlackBrush}"
                              Stretch="Uniform" />
                    </Button>

                    <Button Width="44"
                            Height="44"
                            Margin="6"
                            BorderThickness="0"
                            Command="{Binding ClearPhotoCommand}"
                            Style="{DynamicResource MetroCircleButtonStyle}"
                            TabIndex="8"
                            ToolTip="Стереть текущую фотографию">
                        <Path Width="32"
                              Height="32"
                              Data="{StaticResource ClearIcon}"
                              Fill="{DynamicResource BlackBrush}"
                              Stretch="Uniform" />
                    </Button>
                </StackPanel>
            </StackPanel>

            <Grid Name="CharacterGrid"
                  Grid.Row="0"
                  Grid.Column="1"
                  DataContext="{Binding SelectedItem}">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0"
                           Grid.Column="0"
                           Margin="6"
                           VerticalAlignment="Center"
                           Text="Фамилия:" />
                <TextBlock Grid.Row="1"
                           Grid.Column="0"
                           Margin="6"
                           VerticalAlignment="Center"
                           Text="Имя:" />
                <TextBlock Grid.Row="2"
                           Grid.Column="0"
                           Margin="6"
                           VerticalAlignment="Center"
                           Text="Отчество:" />
                <TextBlock Grid.Row="3"
                           Grid.Column="0"
                           Margin="6"
                           VerticalAlignment="Center"
                           Text="Телефон:" />
                <TextBlock Grid.Row="4"
                           Grid.Column="0"
                           Margin="6"
                           VerticalAlignment="Center"
                           Text="Место жительства:" />
                <TextBlock Grid.Row="5"
                           Grid.Column="0"
                           Margin="6"
                           Text="Примечание:" />

                <TextBox Name="SecondNameTextBox"
                         Grid.Row="0"
                         Grid.Column="1"
                         Margin="6"
                         TabIndex="1"
                         controls:TextboxHelper.IsWaitingForData="True"
                         controls:TextboxHelper.Watermark="Укажите фамилию"
                         d:DataContext="{d:DesignInstance directories:Character}">
                    <TextBox.Text>
                        <Binding Mode="TwoWay"
                         Path="LastName"
                         UpdateSourceTrigger="PropertyChanged"
                         ValidatesOnExceptions="True">
                            <Binding.ValidationRules>
                                <validators:StringNotEmptyValidator />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
                <TextBox Grid.Row="1"
                         Grid.Column="1"
                         Margin="6"
                         TabIndex="2"
                         controls:TextboxHelper.IsWaitingForData="True"
                         controls:TextboxHelper.Watermark="Укажите имя"
                         d:DataContext="{d:DesignInstance directories:Character}">
                    <TextBox.Text>
                        <Binding Mode="TwoWay"
                         Path="FirstName"
                         UpdateSourceTrigger="PropertyChanged"
                         ValidatesOnExceptions="True">
                            <Binding.ValidationRules>
                                <validators:StringNotEmptyValidator />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
                <TextBox Grid.Row="2"
                         Grid.Column="1"
                         Margin="6"
                         TabIndex="3"
                         Text="{Binding MiddleName}"
                         controls:TextboxHelper.Watermark="Укажите отчество"
                         d:DataContext="{d:DesignInstance directories:Character}" />
                <TextBox Grid.Row="3"
                         Grid.Column="1"
                         Margin="6"
                         TabIndex="4"
                         controls:TextboxHelper.IsWaitingForData="True"
                         controls:TextboxHelper.Watermark="Укажите контактные телефоны"
                         d:DataContext="{d:DesignInstance directories:Character}">
                    <TextBox.Text>
                        <Binding Mode="TwoWay"
                         Path="Phone"
                         UpdateSourceTrigger="PropertyChanged"
                         ValidatesOnExceptions="True">
                            <Binding.ValidationRules>
                                <validators:StringNotEmptyValidator />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>
                <TextBox Grid.Row="4"
                         Grid.Column="1"
                         Margin="6"
                         TabIndex="5"
                         Text="{Binding PlaceOfResidence}"
                         controls:TextboxHelper.Watermark="Укажите место жительства"
                         d:DataContext="{d:DesignInstance directories:Character}" />
                <xctk:RichTextBox x:Name="NoteRichTextBox"
                                  Grid.Row="5"
                                  Grid.Column="1"
                                  Margin="6"
                                  HorizontalAlignment="Left"
                                  VerticalAlignment="Stretch"
                                  FlowDirection="LeftToRight"
                                  IsReadOnly="False"
                                  TabIndex="6"
                                  Text="{Binding Note}"
                                  d:DataContext="{d:DesignInstance directories:Character}">
                    <xctk:RichTextBox.Document>
                        <FlowDocument PageWidth="{Binding ElementName=NoteRichTextBox, Path=ActualWidth}" />
                    </xctk:RichTextBox.Document>
                </xctk:RichTextBox>
            </Grid>
        </Grid>
    </Grid>
</UserControl>
